# nx

import networkx as nx
import matplotlib.pyplot as plt

g = nx.Graph()

g.add_nodes_from([1, 'A', 2, 3, 'B'])
g.add_edges_from([(1,2), ('A', 'B'), (1, 3), (2, 'A'), (3, 'B')])

print("节点：", g.nodes())
print("边：", g.edges())
print("节点数量", g.number_of_nodes())
print("边数量", g.number_of_edges())
print("节点1的邻居", list(g.neighbors(1)))

nx.draw(g, with_labels=True, node_color='skyblue', node_size=800)
plt.show()
